//import static java.lang.Math.pow;
//
////继承
//abstract class Shape{
//    public double P=3.14159f;
//    abstract double fun();
//}
//class Circle extends Shape{
//    public double x;
//    public Circle(int x){
//        this.x=x;
//    }
//    public double fun(){
//        //return P*(x*x);
//        return P*(pow(x,2));
//    }
//}
//class Square extends Shape{
//    public double a;
//    public double b;
//    public Square(int a,int b){
//        this.a=a;
//        this.b=b;
//    }
//    public double fun(){
//        return a*b;
//    }
//}
//public class Test {
//    public static void main(String[] args) {
////        Square square=new Square(4,4);
////        System.out.println("正方形的面积："+square.fun());
////
////        Circle circle=new Circle(5);
////        System.out.println("⚪的面积"+circle.fun());
//
//        Shape s=new Circle(4);
//        s.fun();
//    }
//}



abstract class Shape{
    public static final double PI=3.14159;
    abstract double Area();
    abstract double Perimeter();
}
class Circle extends Shape{
    double r=0;
    public Circle(double r){
        this.r=r;
    }
    double Area(){
        return PI*r*r;
    }
    double Perimeter(){
        return 2*PI*r;
    }
}
class Square extends Shape{
    double x=0;
    public Square(double x){
        this.x=x;
    }
    double Area(){
        return x*x;
    }
    double Perimeter(){
        return 4*x;
    }
}
public class Test {
    public static void main(String[] args){
        Circle circle=new Circle(3.1);
        System.out.println("圆的面积为："+circle.Area());
        System.out.println("圆的周长为："+circle.Perimeter());
        Square square=new Square(4);
        System.out.println("正方形的面积为："+square.Area());
        System.out.println("正方形的周长为："+square.Perimeter());

        System.out.println("=======");

        Shape shape=new Circle(3.1);
        System.out.println("圆的面积为："+shape.Area());
        System.out.println("圆的周长为："+shape.Perimeter());
        Shape shape1=new Square(4);
        System.out.println("正方形的面积为："+shape1.Area());
        System.out.println("正方形的周长为："+shape1.Perimeter());
    }
}
